<?php 
class CategoriesController extends AppController {

    public function index() {
    	
    	$data;
    	
    	// If our behavior is not handling model callbacks
    	if (!$this->Category->Behaviors->enabled('Tree')) {
    		//find data like normal
    		$data= $this->Category->find('list', array('order' => 'Category.id ASC'));
    	}else{
    		//generate tree data
    		$data = $this->Category->generateTreeList(
    				null,
    				null,
    				null,
    				'&nbsp;&nbsp;&nbsp;'
    		);
    	}
    	
        echo '<pre>';
        print_r($data);
        
        print_r( $this->Category->verify());
        
        die;
    }
    
    public function beforeFilter(){
    	parent::beforeFilter ();
    	$this->Auth->allow ();
    }
    
    public function add(){
    	// pseudo controller code
    	$data['Category']['name'] = 'Skating 5 child 5';
    	$this->Category->save($data);
    	
    	$this->redirect('/categories/');
    }
    
    public function delete(){
    	// pseudo controller code
    	$this->Category->id = 1;
    	$this->Category->delete();
    	 
    	$this->redirect('/categories/');
    }
}